use crate::co;
use crate::comctl::privs::*;
use crate::decl::*;
use crate::msg::*;
use crate::ole::privs::*;
use crate::prelude::*;
use crate::user::privs::*;
pub struct AddBitmap<'a> {
pub num_images: u32,
pub info: &'a TBADDBITMAP,
}
unsafe impl<'a> MsgSend for AddBitmap<'a> {
type RetType = SysResult<u32>;
fn convert_ret(&self, v: isize) -> Self::RetType {
minus1_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::ADDBITMAP.into(),
wparam: self.num_images as _,
lparam: self.info as *const _ as _,
}
}
}
pub struct AddButtons<'a, 'b> {
pub buttons: &'a mut [TBBUTTON<'b>],
}
unsafe impl<'a, 'b> MsgSend for AddButtons<'a, 'b> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::ADDBUTTONS.into(),
wparam: self.buttons.len() as _,
lparam: self.buttons.as_mut_ptr() as _,
}
}
}
pub struct AddString {
pub texts: ResStrs,
}
unsafe impl MsgSend for AddString {
type RetType = SysResult<u32>;
fn convert_ret(&self, v: isize) -> Self::RetType {
minus1_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::ADDSTRING.into(),
wparam: match &self.texts {
ResStrs::Res(_, hinst) => hinst.ptr() as _,
ResStrs::Strs(_) => 0,
},
lparam: match &self.texts {
ResStrs::Res(res, _) => res.as_ptr() as _,
ResStrs::Strs(strs) => strs.as_ptr() as _,
},
}
}
}
pub_struct_msg_empty! { AutoSize: co::TBM::AUTOSIZE.into();
}
pub struct ButtonCount {}
unsafe impl MsgSend for ButtonCount {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::BUTTONCOUNT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct ButtonStructSize {
pub size: u32,
}
unsafe impl MsgSend for ButtonStructSize {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::BUTTONSTRUCTSIZE.into(),
wparam: self.size as _,
lparam: 0,
}
}
}
pub struct ChangeBitmap {
pub btn_cmd_id: u16,
pub image: IdxCbNone,
}
unsafe impl MsgSend for ChangeBitmap {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::CHANGEBITMAP.into(),
wparam: self.btn_cmd_id as _,
lparam: self.image.into(),
}
}
}
pub struct CheckButton {
pub btn_cmd_id: u16,
pub check: bool,
}
unsafe impl MsgSend for CheckButton {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::CHECKBUTTON.into(),
wparam: self.btn_cmd_id as _,
lparam: self.check as _,
}
}
}
pub struct CommandToIndex {
pub btn_cmd_id: u16,
}
unsafe impl MsgSend for CommandToIndex {
type RetType = Option<u32>;
fn convert_ret(&self, v: isize) -> Self::RetType {
minus1_as_none(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::COMMANDTOINDEX.into(),
wparam: self.btn_cmd_id as _,
lparam: 0,
}
}
}
pub_struct_msg_empty! { Customize: co::TBM::CUSTOMIZE.into();
}
pub struct DeleteButton {
pub btn_index: u32,
}
unsafe impl MsgSend for DeleteButton {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::CHECKBUTTON.into(),
wparam: self.btn_index as _,
lparam: 0,
}
}
}
pub struct EnableButton {
pub btn_cmd_id: u16,
pub enable: bool,
}
unsafe impl MsgSend for EnableButton {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::ENABLEBUTTON.into(),
wparam: self.btn_cmd_id as _,
lparam: self.enable as _,
}
}
}
pub struct GetAnchorHighlight {}
unsafe impl MsgSend for GetAnchorHighlight {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETANCHORHIGHLIGHT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetBitmap {
pub btn_cmd_id: u16,
}
unsafe impl MsgSend for GetBitmap {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETBITMAP.into(),
wparam: self.btn_cmd_id as _,
lparam: 0,
}
}
}
pub struct GetBitmapFlags {}
unsafe impl MsgSend for GetBitmapFlags {
type RetType = co::TBBF;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { co::TBBF::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETBITMAPFLAGS.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetButton<'a, 'b> {
pub btn_index: u32,
pub info: &'a mut TBBUTTON<'b>,
}
unsafe impl<'a, 'b> MsgSend for GetButton<'a, 'b> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETBUTTON.into(),
wparam: self.btn_index as _,
lparam: self.info as *mut _ as _,
}
}
}
pub struct GetButtonInfo<'a, 'b> {
pub btn_cmd_id: u16,
pub info: &'a mut TBBUTTONINFO<'b>,
}
unsafe impl<'a, 'b> MsgSend for GetButtonInfo<'a, 'b> {
type RetType = SysResult<u32>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETBUTTONINFO.into(),
wparam: self.btn_cmd_id as _,
lparam: self.info as *mut _ as _,
}
}
}
pub struct GetButtonSize {}
unsafe impl MsgSend for GetButtonSize {
type RetType = SIZE;
fn convert_ret(&self, v: isize) -> Self::RetType {
SIZE::from(v as u32)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETBUTTONSIZE.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetButtonText<'a> {
pub btn_cmd_id: u16,
pub text: &'a mut WString,
}
unsafe impl<'a> MsgSend for GetButtonText<'a> {
type RetType = SysResult<u32>;
fn convert_ret(&self, v: isize) -> Self::RetType {
minus1_as_badargs(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETBUTTONTEXT.into(),
wparam: self.btn_cmd_id as _,
lparam: unsafe { self.text.as_mut_ptr() } as _,
}
}
}
pub struct GetColorScheme<'a> {
pub scheme: &'a mut COLORSCHEME,
}
unsafe impl<'a> MsgSend for GetColorScheme<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETCOLORSCHEME.into(),
wparam: 0,
lparam: self.scheme as *mut _ as _,
}
}
}
pub struct GetDisabledImageList {}
unsafe impl MsgSend for GetDisabledImageList {
type RetType = Option<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETDISABLEDIMAGELIST.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetExtendedStyle {}
unsafe impl MsgSend for GetExtendedStyle {
type RetType = co::TBSTYLE_EX;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { co::TBSTYLE_EX::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETEXTENDEDSTYLE.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetHotImageList {}
unsafe impl MsgSend for GetHotImageList {
type RetType = Option<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETHOTIMAGELIST.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetHotItem {}
unsafe impl MsgSend for GetHotItem {
type RetType = Option<u32>;
fn convert_ret(&self, v: isize) -> Self::RetType {
minus1_as_none(v).map(|v| v as _)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETHOTITEM.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetIdealSize<'a> {
pub get_height: bool,
pub size: &'a mut SIZE,
}
unsafe impl<'a> MsgSend for GetIdealSize<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETIDEALSIZE.into(),
wparam: self.get_height as _,
lparam: self.size as *mut _ as _,
}
}
}
pub struct GetImageList {}
unsafe impl MsgSend for GetImageList {
type RetType = Option<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETIMAGELIST.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetImageListCount {}
unsafe impl MsgSend for GetImageListCount {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETIMAGELISTCOUNT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetInsertMark<'a> {
pub info: &'a mut TBINSERTMARK,
}
unsafe impl<'a> MsgSend for GetInsertMark<'a> {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETINSERTMARK.into(),
wparam: 0,
lparam: self.info as *mut _ as _,
}
}
}
pub struct GetInsertMarkColor {}
unsafe impl MsgSend for GetInsertMarkColor {
type RetType = COLORREF;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { COLORREF::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETINSERTMARKCOLOR.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetItemDropdownRect<'a> {
pub item_index: u32,
pub rect: &'a mut RECT,
}
unsafe impl<'a> MsgSend for GetItemDropdownRect<'a> {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETITEMDROPDOWNRECT.into(),
wparam: self.item_index as _,
lparam: self.rect as *mut _ as _,
}
}
}
pub struct GetItemRect<'a> {
pub btn_index: u32,
pub rect: &'a mut RECT,
}
unsafe impl<'a> MsgSend for GetItemRect<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETITEMRECT.into(),
wparam: self.btn_index as _,
lparam: self.rect as *mut _ as _,
}
}
}
pub struct GetMaxSize<'a> {
pub size: &'a mut SIZE,
}
unsafe impl<'a> MsgSend for GetMaxSize<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETMAXSIZE.into(),
wparam: 0,
lparam: self.size as *mut _ as _,
}
}
}
pub struct GetMetrics<'a> {
pub metrics: &'a mut TBMETRICS,
}
unsafe impl<'a> MsgSend for GetMetrics<'a> {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETMETRICS.into(),
wparam: 0,
lparam: self.metrics as *mut _ as _,
}
}
}
pub struct GetObject<'a> {
pub obj: &'a IDropTarget,
}
unsafe impl<'a> MsgSend for GetObject<'a> {
type RetType = HrResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
ok_to_hrresult(v as _)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETOBJECT.into(),
wparam: &IDropTarget::IID as *const _ as _,
lparam: &self.obj.ptr() as *const _ as _,
}
}
}
pub struct GetPadding {}
unsafe impl MsgSend for GetPadding {
type RetType = (u16, u16);
fn convert_ret(&self, v: isize) -> Self::RetType {
(LOWORD(v as _), HIWORD(v as _))
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETPADDING.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetPressedImageList {}
unsafe impl MsgSend for GetPressedImageList {
type RetType = Option<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|p| unsafe { HIMAGELIST::from_ptr(p as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETPRESSEDIMAGELIST.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetRect<'a> {
pub cmd_id: u16,
pub rect: &'a mut RECT,
}
unsafe impl<'a> MsgSend for GetRect<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETRECT.into(),
wparam: self.cmd_id as _,
lparam: self.rect as *mut _ as _,
}
}
}
pub struct GetRows {}
unsafe impl MsgSend for GetRows {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETROWS.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetState {
pub cmd_id: u16,
}
unsafe impl MsgSend for GetState {
type RetType = SysResult<co::TBSTATE>;
fn convert_ret(&self, v: isize) -> Self::RetType {
minus1_as_badargs(v).map(|v| unsafe { co::TBSTATE::from_raw(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETSTATE.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct GetString<'a> {
pub index: u16,
pub text: &'a mut WString,
}
unsafe impl<'a> MsgSend for GetString<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETSTRING.into(),
wparam: MAKEDWORD(self.text.buf_len() as _, self.index) as _,
lparam: unsafe { self.text.as_mut_ptr() } as _,
}
}
}
pub struct GetStyle {}
unsafe impl MsgSend for GetStyle {
type RetType = co::BTNS;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { co::BTNS::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETSTYLE.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetTextRows {}
unsafe impl MsgSend for GetTextRows {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETTEXTROWS.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetTooltips {}
unsafe impl MsgSend for GetTooltips {
type RetType = Option<HWND>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HWND::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETTOOLTIPS.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct GetUnicodeFormat {}
unsafe impl MsgSend for GetUnicodeFormat {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::GETUNICODEFORMAT.into(),
wparam: 0,
lparam: 0,
}
}
}
pub struct HideButton {
pub cmd_id: u16,
pub hide: bool,
}
unsafe impl MsgSend for HideButton {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::HIDEBUTTON.into(),
wparam: self.cmd_id as _,
lparam: MAKEDWORD(self.hide as _, 0) as _,
}
}
}
pub struct HitTest<'a> {
pub coords: &'a mut POINT,
}
unsafe impl<'a> MsgSend for HitTest<'a> {
type RetType = i32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::HITTEST.into(),
wparam: 0,
lparam: self.coords as *mut _ as _,
}
}
}
pub struct Indeterminate {
pub cmd_id: u16,
pub indeterminate: bool,
}
unsafe impl MsgSend for Indeterminate {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::INDETERMINATE.into(),
wparam: self.cmd_id as _,
lparam: MAKEDWORD(self.indeterminate as _, 0) as _,
}
}
}
pub struct InsertButton<'a, 'b> {
pub index: u32,
pub button: &'a TBBUTTON<'b>,
}
unsafe impl<'a, 'b> MsgSend for InsertButton<'a, 'b> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::INSERTBUTTON.into(),
wparam: self.index as _,
lparam: self.button as *const _ as _,
}
}
}
pub struct InsertMarkHitTest<'a, 'b> {
pub coords: &'a POINT,
pub info: &'b mut TBINSERTMARK,
}
unsafe impl<'a, 'b> MsgSend for InsertMarkHitTest<'a, 'b> {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::INSERTMARKHITTEST.into(),
wparam: self.coords as *const _ as _,
lparam: self.info as *mut _ as _,
}
}
}
pub struct IsButtonChecked {
pub cmd_id: u16,
}
unsafe impl MsgSend for IsButtonChecked {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::ISBUTTONCHECKED.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct IsButtonEnabled {
pub cmd_id: u16,
}
unsafe impl MsgSend for IsButtonEnabled {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::ISBUTTONENABLED.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct IsButtonHidden {
pub cmd_id: u16,
}
unsafe impl MsgSend for IsButtonHidden {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::ISBUTTONHIDDEN.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct IsButtonHighlighted {
pub cmd_id: u16,
}
unsafe impl MsgSend for IsButtonHighlighted {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::ISBUTTONHIGHLIGHTED.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct IsButtonIndeterminate {
pub cmd_id: u16,
}
unsafe impl MsgSend for IsButtonIndeterminate {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::ISBUTTONINDETERMINATE.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct IsButtonPressed {
pub cmd_id: u16,
}
unsafe impl MsgSend for IsButtonPressed {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::ISBUTTONPRESSED.into(),
wparam: self.cmd_id as _,
lparam: 0,
}
}
}
pub struct LoadImages {
pub img_list: co::IDB,
}
unsafe impl MsgSend for LoadImages {
type RetType = u32;
fn convert_ret(&self, v: isize) -> Self::RetType {
v as _
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::LOADIMAGES.into(),
wparam: self.img_list.raw() as _,
lparam: HINST_COMMCTRL,
}
}
}
pub struct MapAccelerator<'a> {
pub character: char,
pub cmd_id: &'a mut u16,
}
unsafe impl<'a> MsgSend for MapAccelerator<'a> {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::MAPACCELERATOR.into(),
wparam: self.character as _,
lparam: self.cmd_id as *mut _ as _,
}
}
}
pub struct MarkButton {
pub cmd_id: u16,
pub highlight: bool,
}
unsafe impl MsgSend for MarkButton {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::MARKBUTTON.into(),
wparam: self.cmd_id as _,
lparam: MAKEDWORD(self.highlight as _, 0) as _,
}
}
}
pub struct MoveButton {
pub btn_index: u32,
pub dest_index: u32,
}
unsafe impl MsgSend for MoveButton {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::MOVEBUTTON.into(),
wparam: self.btn_index as _,
lparam: self.dest_index as _,
}
}
}
pub struct PressButton {
pub cmd_id: u16,
pub press: bool,
}
unsafe impl MsgSend for PressButton {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::PRESSBUTTON.into(),
wparam: self.cmd_id as _,
lparam: MAKEDWORD(self.press as _, 0) as _,
}
}
}
pub struct ReplaceBitmap<'a> {
pub info: &'a TBREPLACEBITMAP,
}
unsafe impl<'a> MsgSend for ReplaceBitmap<'a> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::REPLACEBITMAP.into(),
wparam: 0,
lparam: self.info as *const _ as _,
}
}
}
pub struct SaveRestore<'a, 'b> {
pub save: bool,
pub info: &'b mut TBSAVEPARAMS<'a>,
}
unsafe impl<'a, 'b> MsgSend for SaveRestore<'a, 'b> {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SAVERESTORE.into(),
wparam: self.save as _,
lparam: self.info as *const _ as _,
}
}
}
pub struct SetAnchorHighlight {
pub enable: bool,
}
unsafe impl MsgSend for SetAnchorHighlight {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETANCHORHIGHLIGHT.into(),
wparam: self.enable as _,
lparam: 0,
}
}
}
pub struct SetBitmapSize {
pub width: u16,
pub height: u16,
}
unsafe impl MsgSend for SetBitmapSize {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETBITMAPSIZE.into(),
wparam: 0,
lparam: MAKEDWORD(self.width, self.height) as _,
}
}
}
pub struct SetButtonInfo<'a, 'b> {
pub btn_cmd_id: u16,
pub info: &'b TBBUTTONINFO<'a>,
}
unsafe impl<'a, 'b> MsgSend for SetButtonInfo<'a, 'b> {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETBUTTONINFO.into(),
wparam: self.btn_cmd_id as _,
lparam: self.info as *const _ as _,
}
}
}
pub struct SetButtonSize {
pub width: u16,
pub height: u16,
}
unsafe impl MsgSend for SetButtonSize {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETBUTTONSIZE.into(),
wparam: 0,
lparam: MAKEDWORD(self.width, self.height) as _,
}
}
}
pub struct SetButtonWidth {
pub min_width: u16,
pub max_width: u16,
}
unsafe impl MsgSend for SetButtonWidth {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETBUTTONWIDTH.into(),
wparam: 0,
lparam: MAKEDWORD(self.min_width, self.max_width) as _,
}
}
}
pub struct SetCmdId {
pub btn_index: u32,
pub cmd_id: u16,
}
unsafe impl MsgSend for SetCmdId {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETCMDID.into(),
wparam: self.btn_index as _,
lparam: self.cmd_id as _,
}
}
}
pub struct SetColorScheme<'a> {
pub scheme: &'a COLORSCHEME,
}
unsafe impl<'a> MsgSend for SetColorScheme<'a> {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETCOLORSCHEME.into(),
wparam: 0,
lparam: self.scheme as *const _ as _,
}
}
}
pub struct SetDisabledImageList<'a> {
pub himagelist: &'a HIMAGELIST,
}
unsafe impl<'a> MsgSend for SetDisabledImageList<'a> {
type RetType = Option<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETDISABLEDIMAGELIST.into(),
wparam: 0,
lparam: self.himagelist.ptr() as _,
}
}
}
pub struct SetDrawTextFlags {
pub mask: co::DT,
pub draw: co::DT,
}
unsafe impl MsgSend for SetDrawTextFlags {
type RetType = co::DT;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { co::DT::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETDRAWTEXTFLAGS.into(),
wparam: self.mask.raw() as _,
lparam: self.draw.raw() as _,
}
}
}
pub struct SetExtendedStyle {
pub style: co::TBSTYLE_EX,
}
unsafe impl MsgSend for SetExtendedStyle {
type RetType = co::TBSTYLE_EX;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { co::TBSTYLE_EX::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETEXTENDEDSTYLE.into(),
wparam: 0,
lparam: self.style.raw() as _,
}
}
}
pub struct SetHotImageList<'a> {
pub himagelist: &'a HIMAGELIST,
}
unsafe impl<'a> MsgSend for SetHotImageList<'a> {
type RetType = Option<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETHOTIMAGELIST.into(),
wparam: 0,
lparam: self.himagelist.ptr() as _,
}
}
}
pub struct SetHotItem {
pub index: Option<u32>,
}
unsafe impl MsgSend for SetHotItem {
type RetType = Option<u32>;
fn convert_ret(&self, v: isize) -> Self::RetType {
minus1_as_none(v).map(|idx| idx as _)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETHOTITEM.into(),
wparam: self.index.map_or(-1, |idx| idx as i32) as _,
lparam: 0,
}
}
}
pub struct SetHotItem2 {
pub index: Option<u32>,
pub flags: co::HICF,
}
unsafe impl MsgSend for SetHotItem2 {
type RetType = Option<u32>;
fn convert_ret(&self, v: isize) -> Self::RetType {
minus1_as_none(v).map(|idx| idx as _)
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETHOTITEM2.into(),
wparam: self.index.map_or(-1, |idx| idx as i32) as _,
lparam: self.flags.raw() as _,
}
}
}
pub struct SetImageList {
pub himagelist: HIMAGELIST,
}
unsafe impl MsgSend for SetImageList {
type RetType = Option<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETIMAGELIST.into(),
wparam: 0,
lparam: self.himagelist.ptr() as _,
}
}
}
pub struct SetIndent {
pub pixels: u32,
}
unsafe impl MsgSend for SetIndent {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETINDENT.into(),
wparam: self.pixels as _,
lparam: 0,
}
}
}
pub struct SetInsertMark<'a> {
pub info: &'a TBINSERTMARK,
}
unsafe impl<'a> MsgSend for SetInsertMark<'a> {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETINSERTMARK.into(),
wparam: 0,
lparam: self.info as *const _ as _,
}
}
}
pub struct SetInsertMarkColor {
pub color: COLORREF,
}
unsafe impl MsgSend for SetInsertMarkColor {
type RetType = COLORREF;
fn convert_ret(&self, v: isize) -> Self::RetType {
unsafe { COLORREF::from_raw(v as _) }
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETINSERTMARKCOLOR.into(),
wparam: 0,
lparam: u32::from(self.color) as _,
}
}
}
pub struct SetListGap {
pub gap: u32,
}
unsafe impl MsgSend for SetListGap {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETLISTGAP.into(),
wparam: self.gap as _,
lparam: 0,
}
}
}
pub struct SetMaxTextRows {
pub max_rows: u32,
}
unsafe impl MsgSend for SetMaxTextRows {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETMAXTEXTROWS.into(),
wparam: self.max_rows as _,
lparam: 0,
}
}
}
pub struct SetMetrics<'a> {
pub metrics: &'a TBMETRICS,
}
unsafe impl<'a> MsgSend for SetMetrics<'a> {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETMETRICS.into(),
wparam: 0,
lparam: self.metrics as *const _ as _,
}
}
}
pub struct SetPadding {
pub horizontal: u16,
pub vertical: u16,
}
unsafe impl MsgSend for SetPadding {
type RetType = (u16, u16);
fn convert_ret(&self, v: isize) -> Self::RetType {
(LOWORD(v as _), HIWORD(v as _))
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETPADDING.into(),
wparam: 0,
lparam: MAKEDWORD(self.horizontal, self.vertical) as _,
}
}
}
pub struct SetParent<'a> {
pub hparent: &'a HWND
}
unsafe impl<'a> MsgSend for SetParent<'a> {
type RetType = Option<HWND>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HWND::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETPARENT.into(),
wparam: 0,
lparam: self.hparent.ptr() as _,
}
}
}
pub struct SetPressedImageList<'a> {
pub index: u32,
pub himagelist: Option<&'a HIMAGELIST>,
}
unsafe impl<'a> MsgSend for SetPressedImageList<'a> {
type RetType = Option<HIMAGELIST>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_none(v).map(|v| unsafe { HIMAGELIST::from_ptr(v as _) })
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETPRESSEDIMAGELIST.into(),
wparam: self.index as _,
lparam: self.himagelist.map_or(0, |h| h.ptr() as _),
}
}
}
pub struct SetRows<'a> {
pub num_rows: u16,
pub create_more: bool,
pub bounds: &'a mut RECT,
}
unsafe impl<'a> MsgSend for SetRows<'a> {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETROWS.into(),
wparam: MAKEDWORD(self.num_rows, self.create_more as _) as _,
lparam: self.bounds as *mut _ as _,
}
}
}
pub struct SetState {
pub btn_cmd_id: u16,
pub state: co::BTNS,
}
unsafe impl MsgSend for SetState {
type RetType = SysResult<()>;
fn convert_ret(&self, v: isize) -> Self::RetType {
zero_as_badargs(v).map(|_| ())
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETSTATE.into(),
wparam: self.btn_cmd_id as _,
lparam: MAKEDWORD(self.state.raw() as _, 0) as _,
}
}
}
pub struct SetStyle {
pub style: co::BTNS,
}
unsafe impl MsgSend for SetStyle {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETSTYLE.into(),
wparam: 0,
lparam: self.style.raw() as _,
}
}
}
pub struct SetTooltips<'a> {
pub htooltips: Option<&'a HWND>,
}
unsafe impl<'a> MsgSend for SetTooltips<'a> {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETTOOLTIPS.into(),
wparam: self.htooltips.map_or(0, |h| h.ptr() as _),
lparam: 0,
}
}
}
pub struct SetUnicodeFormat {
pub use_unicode: bool,
}
unsafe impl MsgSend for SetUnicodeFormat {
type RetType = bool;
fn convert_ret(&self, v: isize) -> Self::RetType {
v != 0
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETUNICODEFORMAT.into(),
wparam: self.use_unicode as _,
lparam: 0,
}
}
}
pub struct SetWindowTheme {
pub visual_style: WString,
}
unsafe impl MsgSend for SetWindowTheme {
type RetType = ();
fn convert_ret(&self, _: isize) -> Self::RetType {
()
}
fn as_generic_wm(&mut self) -> WndMsg {
WndMsg {
msg_id: co::TBM::SETWINDOWTHEME.into(),
wparam: 0,
lparam: self.visual_style.as_ptr() as _,
}
}
}